# Create your models here.
from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField
from django.db import models

from type.models import CommonTypeModel


class CommonModel(models.Model):
    title = models.CharField(max_length=200, blank=True, null=True, verbose_name='常识标题')
    title_en = models.CharField(max_length=200, blank=True, null=True, verbose_name='英文标题')
    type = models.ForeignKey(to=CommonTypeModel, on_delete=models.SET_NULL, blank=True, null=True,
                             related_name='common',
                             verbose_name='常识类别')
    body = RichTextUploadingField(verbose_name='中文')
    body_en = RichTextUploadingField(verbose_name='英文')
    create_time = models.DateTimeField(auto_now=True, blank=True, null=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now_add=True, verbose_name='最后修改时间', blank=True, null=True)

    def __str__(self):
        return self.title

    class Meta:
        db_table = 't_common_sense'
        verbose_name = '常识'
        verbose_name_plural = '常识'
